import React, { useEffect } from 'react'
import { useSelector } from "react-redux"
import OrderHeader from "../../components/PubHeader"
import UserInfo from "./UserInfo"
import OrderList from "./OrderList"
import Exit from "./Exit"

export default function Order ({ history }) {

  const city = useSelector(state => state.city.city)
  // console.log(city);
  // const username = useSelector(state => state.auth.user.username)
  // console.log(username);
  const username = localStorage.getItem("username");


  useEffect(() => {
    if (!username) {
      history.push("/login")
    }
  }, [])


  return (
    <div>
      <OrderHeader title="订单详情" />
      {
        username ? <UserInfo city={city} username={username} /> :
          <div></div>
      }
      {
        username ? <OrderList user={username} /> :
          <div></div>
      }


      <Exit />
    </div>
  )
}
